//
//  GAKKIBaseCollectionViewController+EmptyData.m
//  GANGAIKit
//
//  Created by fh on 2019/11/7.
//  Copyright © 2019 cashchina. All rights reserved.
//

#import "GAKKIBaseCollectionViewController+EmptyData.h"
#import <objc/runtime.h>
#import <SJAttributesFactory/SJAttributesFactory.h>

@interface GAKKIBaseCollectionViewController ()

@end


@implementation GAKKIBaseCollectionViewController (EmptyData)

#pragma mark - DZNEmptyDataSetSource
// 空数据时的标题文字
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
    WeakSelf;
    return sj_makeAttributesString(^(SJAttributeWorker *make) {
        make
        .append(kEmptyString(weakSelf.nullDataTitleText))
        .font([UIFont systemFontOfSize:16])
        .alignment(NSTextAlignmentCenter)
        .textColor([UIColor grayColor]);
    });
}

// 空数据时的描述文字
- (NSAttributedString *)descriptionForEmptyDataSet:(UIScrollView *)scrollView {
    WeakSelf;
    return sj_makeAttributesString(^(SJAttributeWorker *make) {
        make
        .append(kEmptyString(weakSelf.nullDataDescriptionText))
        .font([UIFont systemFontOfSize:16])
        .alignment(NSTextAlignmentCenter)
        .textColor([UIColor grayColor]);
    });
}

// 空数据时的图片
- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView {
    return [UIImage imageNamed:@"empty_placeholder"];
}
- (UIColor *)imageTintColorForEmptyDataSet:(UIScrollView *)scrollView {
    return nil;
}

//// 空数据时按钮的标题文字
//- (NSAttributedString *)buttonTitleForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state {
//    return [NSMutableAttributedString gg_makeMutableAttributedString:^(NSMutableAttributedString *primaryAttStr) {
//        primaryAttStr
//        .appendAllArgumentMutableAttributedString(@"空数据按钮标题", [UIColor grayColor], [UIFont systemFontOfSize:16], NSTextAlignmentCenter, NO, 0, NO, 0);
//    }];
//}
//// 空数据时按钮的图片
//- (UIImage *)buttonImageForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state {
//    return [UIImage imageNamed:@"empty_placeholder"];;
//}
//// 空数据时按钮的背景图片
//- (UIImage *)buttonBackgroundImageForEmptyDataSet:(UIScrollView *)scrollView forState:(UIControlState)state {
//    return [UIImage imageNamed:@"empty_placeholder"];;
//}

//// 空视图的背景颜色
//- (UIColor *)backgroundColorForEmptyDataSet:(UIScrollView *)scrollView {
//    return [UIColor greenColor];
//}
- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
    return 0;
}

- (CGFloat)spaceHeightForEmptyDataSet:(UIScrollView *)scrollView {
    return 0;
}

- (UIView *)customViewForEmptyDataSet:(UIScrollView *)scrollView {
    return nil;
}

#pragma mark - DZNEmptyDataSetDelegate
- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView {
    return YES;
}
//- (BOOL)emptyDataSetShouldFadeIn:(UIScrollView *)scrollView {
//    return YES;
//}
//- (BOOL)emptyDataSetShouldBeForcedToDisplay:(UIScrollView *)scrollView {
//    return YES;
//}
//- (BOOL)emptyDataSetShouldDisplay:(UIScrollView *)scrollView {
//    return YES;
//}
//- (BOOL)emptyDataSetShouldAllowTouch:(UIScrollView *)scrollView {
//    return YES;
//}
//- (BOOL)emptyDataSetShouldAnimateImageView:(UIScrollView *)scrollView {
//    return YES;
//}

- (void)emptyDataSet:(UIScrollView *)scrollView didTapView:(UIView *)view {
    
}
- (void)emptyDataSet:(UIScrollView *)scrollView didTapButton:(UIButton *)button {
    
}
- (void)emptyDataSetWillAppear:(UIScrollView *)scrollView {
    
}

- (void)emptyDataSetDidAppear:(UIScrollView *)scrollView {
    
}
- (void)emptyDataSetWillDisappear:(UIScrollView *)scrollView {
    
}
- (void)emptyDataSetDidDisappear:(UIScrollView *)scrollView {
    
}

#pragma mark - Setter and getter
- (NSString *)nullDataTitleText {
    return objc_getAssociatedObject(self, _cmd);
}
- (void)setNullDataTitleText:(NSString *)nullDataTitleText {
    objc_setAssociatedObject(self,@selector(nullDataTitleText),nullDataTitleText,OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (NSString *)nullDataDescriptionText {
    return objc_getAssociatedObject(self, _cmd);
}
- (void)setNullDataDescriptionText:(NSString *)nullDataDescriptionText {
    objc_setAssociatedObject(self,@selector(nullDataDescriptionText),nullDataDescriptionText,OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

@end
